<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <link rel="stylesheet" href="css/font.css">
    <link rel="stylesheet" href="css/login.css">
    <link rel="stylesheet" href="css/xadmin.css">
    <link rel="stylesheet" href="layui/css/layui.css">
    <script src="layui/layui.js"></script>
</head>
<body class="login-bg">
<div class="login layui-anim layui-anim-up">
    <div class="message">阳光物流管理系统</div>
    <div id="darkbannerwrap"></div>
    <form id="address" method="post" class="layui-form">
        <input placeholder="真实姓名" type="text" name="cname" lay-verify="required" class="layui-input">
        <hr class="hr15">
        <input placeholder="联系方式" type="text" name="cphone" lay-verify="required" class="layui-input">
        <hr class="hr15">
        <input placeholder="用户名" type="text" name="user_name" lay-verify="required" class="layui-input">
        <hr class="hr15">
        <input type="password" name="password" lay-verify="required" placeholder="密码" class="layui-input">
        <hr class="hr15">
        <input type="button" id="btnLogin" value="注册" lay-submit lay-filter="btnLogin" style="width:100%">
        <hr class="hr20">
    </form>
</div>
</body>
</html>
<script src="js/jquery-3.6.0.js"></script>
<script>
    layui.use(['layer','form'],function (){
        var form = layui.form;
        $(function () {
            form.on('submit(btnLogin)',function (){
                var data = $("#address").serialize();
                $.post("http://localhost:8080/add", data, function (rs) {
                    if (rs.code == 0) {
                        layer.msg("注册成功", {icon: 6});
                        setTimeout(function () {
                                location.href = 'login.html';
                            },
                            1000
                        );
                    } else {
                        layer.msg("请重新注册", {icon: 5});
                        setTimeout(function () {
                                location.reload();//刷新页面
                            },
                            1000
                        );
                    }
                });
            });
        })
    });
</script>